﻿using System;
using System.Data;
using System.Data.SqlClient;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;

namespace ASPNETVN.PORTAL.Modules.SCHEDULE.Components
{
    public partial class Item
    {
        public static DataSet SelectBy_DepartmentID(int DepartmentID)
        {
            string spName = "p_SCHEDULE_Items_SelectBy_DepartmentID";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);
            db.AddInParameter(dbCommand, "@DepartmentID", SqlDbType.Int, DepartmentID);
            return db.ExecuteDataSet(dbCommand);
        }

        public static int GetItemCount(Guid moduleID, int DepartmentID)
        {
            string spName = "[dbo].[p_SCHEDULE_Item_Count]";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);
            db.AddInParameter(dbCommand, "@ModuleID", SqlDbType.UniqueIdentifier, moduleID);
            db.AddInParameter(dbCommand, "@DepartmentID", SqlDbType.Int, DepartmentID);

            return Convert.ToInt32(db.ExecuteScalar(dbCommand));
        }
    }
}
